<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/include.jsp"%>
<head>
	<script type="text/javascript" src='<s:url value="/scripts/CustomTreeUI.js" includeParams="none"/>'></script>
	<link rel="stylesheet" type="text/css" href='<s:url value="/scripts/column-tree.css" includeParams="none"/>'/>
</head>
<body>
<div class="tleft"></div>
<div class="tright"></div>
<div class="tbg"></div>

<s:form  id="multiListForm" namespace="/querythemes" action="">
<div id="ids" style="display:none"></div>
<table align="center"  cellpadding="1" cellspacing="1" class="tablelist">
	<s:if test="hasErrors()">
		<s:if test="hasFieldErrors()">
			<tr align="center">
				<td class="tableHeader2"><font color="red" size="4"><s:fielderror/></font></td>
				<td class="tableHeader2"></td>
			</tr>
		</s:if>
		<s:if test="hasActionErrors">
			<tr align="center">
				<td class="tableHeader2"><font color="blue"><s:actionerror/></font></td>
				<td class="tableHeader2"></td>
			</tr>
		</s:if>	
	</s:if>	
	<tr class="listr2">
		<td colspan="4">
			<table align="center"  cellpadding="0" cellspacing="0" class="tablelist">
				<tr class="listr2">
					<td align="right">
						<table align="center"  cellpadding="0" cellspacing="0" class="tablelist">
							<tr class="listr2">
							   <td align="right" style="width:0%">
							   		<s:hidden name="qdCompareCond.id" id="qdCompareCond.id"></s:hidden>
							   </td>
							   <td align="left">待选择数据列表:</td>								
							</tr>
						</table>						
					</td>
					<td align="center" rowspan="2" style="width:10%">
							
							<input type="button" name="Submit2" value=">>" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDest('sourceFieldIds','targetFieldIds','checked')" />
							
							<br>
							<input type="button" name="Submit2" value=">>>>" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDest('sourceFieldIds','targetFieldIds','all')" />
							
							<br>
							<input type="button" name="Submit2" value="<<" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDest('targetFieldIds','sourceFieldIds','checked')" />
							
							<br>
							<input type="button" name="Submit2" value="<<<<" class="btn"  onmouseover="this.className='btn_hover'" onmouseout="this.className='btn'" onclick="srcToDest('targetFieldIds','sourceFieldIds','all')"/>							
					</td>				
					<td align="left">
						已选数据列表:
					</td>
				</tr>
				<tr class="listr2">
					<td align="right">
						<s:select id="sourceFieldIds" name="sourceFieldName" list="dataList"  listKey="code" listValue="name" size="30" multiple="true" style="width:100%">						    
					    </s:select>
						
					</td>
					
					<td align="left">
					    <s:select id="targetFieldIds" name="targetFieldName" list='#{}' size="30" multiple="true" style="width:100%">						    
					    </s:select>
					    
						<input type="hidden" id="tIds" name="targetIds" value="">
						<input type="hidden" id="tNames" name="targetNames" value="">
					</td>
				</tr>
			</table>
		</td>
		
	</tr>	
</table>
<div class="tableHeader4"> 
	<input name="" type="button" value="确 定" class="add" onmouseover="this.className='add_hover'" onmouseout="this.className='add'"  onclick="save()"/>
	<input name="" type="button" value="关 闭" class="export" onmouseover="this.className='export_hover'" onmouseout="this.className='export'" onclick="turnOff()" />	 
</div>
</s:form>


<script type="text/javascript">
	function srcToDest(srcid,destid,type){		
		var optionsObjects=document.getElementById(srcid);   
		var optionsSubObjects=document.getElementById(destid);   
		for(var o=optionsObjects.length-1;o>=0;o--){
			if(type=="all"){
		  		var optionsvalue=optionsObjects.options[o].value;   
				var optionstext=optionsObjects.options[o].text;   
				addoptions(destid,optionstext,optionsvalue)   
				optionsObjects.options.remove(o);
		   	}else{    	   
				if(optionsObjects.options[o].selected==true){   
				    var optionsvalue=optionsObjects.options[o].value;   
				    var optionstext=optionsObjects.options[o].text;   
				    addoptions(destid,optionstext,optionsvalue)   
				    optionsObjects.options.remove(o);
		     	}   
		  	}
		}		     
	}
	
	function addoptions(objectid,textvalue,optionsvalue){   
		var optionsSubObjects=document.getElementById(objectid);   
		var hasexist=0;   
		for(var o=0;o<optionsSubObjects.length;o++){   
		 	var optionsvalue_sub=optionsSubObjects.options[o].text;   
		 	if(optionsvalue_sub==textvalue)   
		 		hasexist+=1;   
		}   
		if(hasexist==0){   
		 optionsSubObjects.add(new Option(textvalue, optionsvalue));   
		}   
	}   
	
	function removeoptions(objectid){
		var optionsObjects=document.getElementById(objectid);
		for(var o=optionsObjects.length-1;o>=0;o--){	    	
			optionsObjects.options.remove(o);	    	
	    }    	
	}
	        
   
    
    
    function save(){
    	var srcid="targetFieldIds";
    	var tIds = "tIds";
    	var tNames = "tNames";
    	var targetIds = "";
    	var targetNames = "";
		var optionsObjects=document.getElementById(srcid);	       
		for(var o=optionsObjects.length-1;o>=0;o--){
		 	var optionsvalue=optionsObjects.options[o].value; 
		 	var optionstext=optionsObjects.options[o].text; 
		 	if(targetIds==""){
		 		targetIds = "'"+optionsvalue+"'";
		 	}else{
		 		targetIds = targetIds+",'"+optionsvalue+"'";
		 	}  
		 	
		 	if(targetNames==""){
		 		targetNames = optionstext;
		 	}else{
		 		targetNames = targetNames+","+optionstext;
		 	}				    	
		}		
		var return_array = new Array(2);
	    return_array[0]=targetIds;
	    return_array[1]=targetNames;
	    window.returnValue=return_array;		
		window.close();			    		      
	}
	    
    function turnOff(){
    	window.close();
    }
</script>
</body>